<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        <div class="panel-lead"><em>{:__('商家认证详情')}</em></div>
        <ul class="nav nav-tabs">
            <li class="active"><a href="#basic" data-toggle="tab">{:__('基本信息')}</a></li>
            <li><a href="#license" data-toggle="tab">{:__('证件信息')}</a></li>
        </ul>
    </div>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="basic">
                <div class="row">
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">商家ID:</label>
                            <div class="controls">
                                <div class="form-control-static">{$row.merchant_id}</div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">店铺名称:</label>
                            <div class="controls">
                                <div class="form-control-static">{$row.store_name}</div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">店铺电话:</label>
                            <div class="controls">
                                <div class="form-control-static">{$row.store_phone}</div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">店铺地址:</label>
                            <div class="controls">
                                <div class="form-control-static">{$row.province} {$row.city} {$row.district} {$row.address}</div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">审核状态:</label>
                            <div class="controls">
                                <div class="form-control-static">
                                    {if $row.verification_status == 0}
                                    <span class="label label-default">待审核</span>
                                    {elseif $row.verification_status == 1}
                                    <span class="label label-info">审核中</span>
                                    {elseif $row.verification_status == 2}
                                    <span class="label label-success">审核通过</span>
                                    {elseif $row.verification_status == 3}
                                    <span class="label label-danger">审核不通过</span>
                                    {/if}
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">提交时间:</label>
                            <div class="controls">
                                <div class="form-control-static">{$row.created_at}</div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">审核人:</label>
                            <div class="controls">
                                <div class="form-control-static">{$row.auditor|default='-'}</div>
                            </div>
                        </div>
                    </div>
                    {if $row.verification_status == 3}
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label">拒绝原因:</label>
                            <div class="controls">
                                <div class="form-control-static">{$row.reject_reason}</div>
                            </div>
                        </div>
                    </div>
                    {/if}
                </div>
            </div>
            <div class="tab-pane fade" id="license">
                <div class="row">
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">店铺LOGO:</label>
                            <div class="controls">
                                <div class="form-control-static">
                                    <a href="{$row.store_logo}" target="_blank">
                                        <img src="{$row.store_logo}" alt="店铺LOGO" style="max-width:100px;max-height:100px;">
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">营业执照:</label>
                            <div class="controls">
                                <div class="form-control-static">
                                    <a href="{$row.business_license}" target="_blank">
                                        <img src="{$row.business_license}" alt="营业执照" style="max-width:100px;max-height:100px;">
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">身份证正面:</label>
                            <div class="controls">
                                <div class="form-control-static">
                                    <a href="{$row.id_card_front}" target="_blank">
                                        <img src="{$row.id_card_front}" alt="身份证正面" style="max-width:100px;max-height:100px;">
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6">
                        <div class="form-group">
                            <label class="control-label">身份证反面:</label>
                            <div class="controls">
                                <div class="form-control-static">
                                    <a href="{$row.id_card_back}" target="_blank">
                                        <img src="{$row.id_card_back}" alt="身份证反面" style="max-width:100px;max-height:100px;">
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    {if $row.other_qualification}
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label">其他资质:</label>
                            <div class="controls">
                                <div class="form-control-static">
                                    {foreach name="row.other_qualification|explode=','" item="item"}
                                    <a href="{$item}" target="_blank">
                                        <img src="{$item}" alt="其他资质" style="max-width:100px;max-height:100px;margin-right:10px;">
                                    </a>
                                    {/foreach}
                                </div>
                            </div>
                        </div>
                    </div>
                    {/if}
                </div>
            </div>
        </div>
    </div>
    <div class="panel-footer">
        <div class="row">
            <div class="col-xs-12 col-sm-12">
                <button type="reset" class="btn btn-default btn-embossed btn-close" onclick="Layer.closeAll()">{:__('关闭')}</button>
                {if $row.verification_status == 0 || $row.verification_status == 1}
                <button type="button" class="btn btn-success btn-embossed btn-audit-pass" onclick="auditMerchant(2)">{:__('审核通过')}</button>
                <button type="button" class="btn btn-danger btn-embossed btn-audit-reject" onclick="auditMerchant(3)">{:__('审核未通过')}</button>
                {/if}
            </div>
        </div>
    </div>
</div>

<script>
function auditMerchant(status) {
    var url = '{:url("audit")}?ids={$row.id}';
    if (status == 3) {
        // 审核未通过，弹出拒绝原因输入框
        Layer.prompt({title: '{:__("请输入拒绝原因")}', formType: 2}, function(text, index){
            // 关闭输入框
            Layer.close(index);
            // 提交审核
            Fast.api.ajax({
                url: url,
                data: {row: {verification_status: status, reject_reason: text}}
            }, function (data, ret) {
                Layer.closeAll();
                parent.Layer.alert('审核未通过！', {icon: 2}, function(index) {
                    parent.Layer.close(index);
                    var index = parent.Layer.getFrameIndex(window.name);
                    parent.Layer.close(index);
                });
                parent.$("#table").bootstrapTable('refresh');
                return false;
            });
        });
    } else {
        // 审核通过，直接提交
        Fast.api.ajax({
            url: url,
            data: {row: {verification_status: status}}
        }, function (data, ret) {
            Layer.closeAll();
            parent.Layer.alert('审核已通过！', {icon: 1}, function(index) {
                parent.Layer.close(index);
                var index = parent.Layer.getFrameIndex(window.name);
                parent.Layer.close(index);
            });
            parent.$("#table").bootstrapTable('refresh');
            return false;
        });
    }
}
</script>